package com.yiyan.study.controller;

import com.yiyan.study.model.DemoParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 示例Controller
 */
@RestController
@RequestMapping("/demo")
@Tag(name = "示例Controller")
public class DemoController {

    @Operation(summary = "示例接口-Hello")
    @GetMapping("/hello")
    public String hello() {
        return "Hello World!";
    }

    @Operation(summary = "示例接口-有参")
    @GetMapping("/hello2")
    public String hello2(@Parameter(description = "Query参数") @RequestParam(name = "param") String param) {
        return "Hello " + param;
    }

    @Operation(summary = "示例接口-实体参数")
    @PostMapping("/hello3")
    public String hello3(@RequestBody DemoParam demo) {
        return "Hello " + demo.getUsername();
    }
}